package com.qdu.service.impl;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qdu.entity.Bussiness;
import com.qdu.entity.Manager;
import com.qdu.entity.Usert;
import com.qdu.mapper.ManagerMapper;
import com.qdu.service.ManagerService;

@Service
public class ManagerServiceImpl implements ManagerService {

	
	@Autowired
	private ManagerMapper managerMapper;
	
	public Manager login(String mid,String mpwd) {
		Manager m= managerMapper.getManagerById(mid);
		return m;
	}
	@Override
	public List<Usert> getAllUser() {
		List<Usert> list = managerMapper.getAll();
		return list;
	}
	@Override
	public List<Bussiness> getUnreviewd() {
		List<Bussiness> list = managerMapper.getUnreviewd();
		return list;
	}
	
	@Override
	public List<Map<String,Object>> getUnreviewedList() {
		return managerMapper.getUnreviewedList();
	}
	@Override
	public List<Map<String, Object>> getJobList() {
		return managerMapper.getJobList();
	}
	@Override
	public List<Map<String, Object>> getJobListByTime() {
		return managerMapper.getJobListByTime();
	}
	
	@Transactional
	@Override
	public int deleteUser(String uid) {
		int deleteU = managerMapper.deleteUser(uid);
		int deleteD = managerMapper.deleteUserRoles(uid);
		if(deleteD>0 && deleteU>0) {
			return 200;
		}
		return 500;
	}
	@Transactional
	@Override
	public int updateUserlevel(String uid) {
		return managerMapper.updateUlevel(uid);
	}
	@Transactional
	@Override
	public int updateUserlevelEn(String uid) {
		return managerMapper.updateUlevelEn(uid);
	}
	@Override
	public List<Map<String, Object>> getSearchList() {
		return managerMapper.getSelection();
	}
	@Override
	public List<Map<String, Object>> getBussiness(String bname) {
		
		return managerMapper.getBussiness(bname);
	}
	@Override
	public List<Map<String, Object>> getBussname() {
		// TODO Auto-generated method stub
		return managerMapper.getActivebuss();
	}
	@Override
	public List<Map<String, Object>> getBussbatchid() {
		return managerMapper.getActivebatch();
	}
	@Override
	public int updateRolepwd(String upwd, String uid) {
		return managerMapper.updateRolepwd(upwd, uid);
	}
	@Override
	public List<Map<String, Object>> getHrList() {
		
		return managerMapper.getHr();
	}
	@Override
	public List<Map<String, Object>> getAllBuss() {
		
		return managerMapper.getAllBussiness();
	}
	
	@Transactional
	@Override
	public int disOneBuss(String bid) {
		return managerMapper.disOneBuss(bid);
	}
	
	@Transactional
	@Override
	public int agreeOneBuss(String bid) {
	
		return managerMapper.agreeOneBuss(bid);
	}
	@Override
	public int deleteJob(BigInteger jid) {
		
		return managerMapper.deleteJob(jid);
	}
	@Override
	public List<Map<String, Object>> getJobByBuss(int bid) {
		// TODO Auto-generated method stub
		return managerMapper.getJobByBuss(bid);
	}
	@Override
	public int userstatus(String uid) {
		// TODO Auto-generated method stub
		return managerMapper.userstatus(uid);
	}
	
	
	
	
}
